<template>
  <div>
    <!-- 搜索框 -->
    <van-row>
      <van-cell-group>
        <van-field v-model="value" placeholder="请输入商品名称" />
      </van-cell-group>
    </van-row>
    <van-button class="safs" type="info" @click="prodauct">添加商品</van-button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: ""
    };
  },
  methods: {
    async prodauct() {
      var prd = this.value;
      if (prd.trim()== "") return this.$toast('请输入商品名称');
        const { data: res } = await this.$http.post("/api/addproduct", { name: prd });
        if (res.status !== 0)return this.$toast.fail("商品添加失败");
        this.value = "";
        this.$toast.success("商品添加成功");    
    },
  }
};
</script>
<style lang="less" scoped>
.safs {
  width: 100%;
  font-size: 16px;
}
.van-field {
  height: 150px;
}
</style>
